// pages/my/stockDetails/stockDetails.js
var app = getApp()
Page({
  data: {
    list:[
    // {
    //   date: "2018-07-30",
    //   time:"10: 31",
    //   price:"200",
    //   num:123,
    //   way:"手动输入"
    // }, {
    //     date: "2018-07-30",
    //     time: "10: 31",
    //     price: "300",
    //     num: 123,
    //     way: "自动转入"
    //   }, {
    //     date: "2018-07-30",
    //     time: "10: 31",
    //     price: "200",
    //     num: 123,
    //     way: "自动转入"
    //   }, {
    //     date: "2018-07-30",
    //     time: "10: 31",
    //     num: 123,
    //     price: "200",
    //     way: "自动转入"
    //   }
      ]
  
  },
  onLoad: function (options) {
    let type = options.type
    let productId = options.id
    let versionValueIds = options.ver
    app.getMemInfo().then(res=>{
      let agentId = res.data.agentId
      let accountId = res.data.id
      var data = {
        type,
        productId,
        versionValueIds,
        agentId,
        accountId
      }
      console.log(data)
      let list = []
      app.request('wx_app/agent/stock/flow/list',data,'GET').then(res=>{
        console.log(res)
        res.data.forEach(item=>{
          console.log()
          list.push({
            date:item.stockTime.split('T')[0],
            price:item.price,
            time:item.stockTime.split('T')[1].split('.')[0],
            num:item.stock,
            way:item.stockSource==0?"手动输入":"自动输入"
          })
          this.setData({
            list
          })
        })
      })
    })
  }
})